﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetNuke.Common.Utilities;
using net.diadrasis.dnn.jsImageGallery.Data;

namespace net.diadrasis.dnn.jsImageGallery.Components
{
    public class cImageSectionController
    {
        public static cImageSection GetImageSection(int imgsecId)
        {
            return CBO.FillObject<cImageSection>(DataProvider.Instance().GetImageSection(imgsecId));
        }

        public static List<cImageSection> GetImageSections(int modId)
        {
            return CBO.FillCollection<cImageSection>(DataProvider.Instance().GetImageSections(modId));
        }

        public static void DeleteImageSection(int imgsecId)
        {
            DataProvider.Instance().DeleteImageSection(imgsecId);
            DataProvider.Instance().DeleteSectionImages(imgsecId);
        }

        public static int SaveImageSection(cImageSection imgsec, int tabID)
        {
            if (imgsec.id < 1)
            {
                imgsec.id = DataProvider.Instance().AddImageSection(imgsec);
            }
            else
            {
                DataProvider.Instance().UpdateImageSection(imgsec);
            }
            return imgsec.id;
        }
    }
}